package com.flk.flkelasticsearch.es;

import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;

/**
 * @author xxwy
 * on 2018/11/12 0012
 */
@Configuration
public class ElasticConfig {

    @Autowired
    private TransportClient transportClient;

    //导入
    @Bean
    public MyElasticSearchTemplate myElasticSearchTemplate(){
        return new MyElasticSearchTemplate(transportClient);
    }

    @Bean
    public ElasticsearchTemplate elasticsearchTemplate() {
        try {
            return new ElasticsearchTemplate(transportClient);
        } catch (Exception var4) {
            throw new IllegalStateException(var4);
        }
    }
}
